package com.cmwa.solution.business.customerEquity.navinfo.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cmwa.solution.base.controller.BaseController;
import com.cmwa.solution.base.entity.Page;
import com.cmwa.solution.base.entity.SearchParam;
import com.cmwa.solution.business.customerEquity.navinfo.entity.NavInfoBaseVo;
import com.cmwa.solution.business.customerEquity.navinfo.service.CmwaProductMarketLaunchService;
import com.cmwa.solution.business.customerEquity.navinfo.service.NavInfoService;
import com.cmwa.solution.utils.Echarts;

/**
 * 客户权益核算-净值
 * @author ex-lihui
 *
 */
@Controller
@RequestMapping("/business/customerEquity/navInfo")
public class NavInfoController extends BaseController {

	@Resource
	private NavInfoService navinfoService;
	@Resource
	private CmwaProductMarketLaunchService cmwaProductMarketLaunchService;
	
	/**
	 * 净值查询首页
	 * @param model
	 * @return
	 */
	@RequestMapping("/navInfoView")
	public String navInfoListView(@Param("prdCode") String prdCode,ModelMap model){
		model.addAttribute("prdCode", prdCode);
		return "/business/customerEquity/navInfo/navInfoPage";
	}
	
	/**
	 * 查询列表
	 * @param sp
	 * @return
	 */
	@RequestMapping(value ="/navInfoListPage")
	@ResponseBody
	public Page<NavInfoBaseVo> navInfoLDetail(SearchParam sp){
		Page<NavInfoBaseVo> navList = navinfoService.queryNavListPage(sp);
		return navList;
	}
	
	/**
	 * 导出
	 * @param response
	 * @param sp
	 * @throws IOException
	 */
	@RequestMapping("/exportNavDetail")
	public void exportNavDetail(HttpServletResponse response,SearchParam sp) {
		navinfoService.exportNavDetail(response, sp);
	}

	
	/**
	 * 折线数据
	 */
	@RequestMapping("/queryNavInfoBySolid")
	@ResponseBody
	public Echarts queryNavInfoBySolid(HttpServletResponse response,SearchParam sp) {
		return navinfoService.queryNavInfoBySolid(response,sp);
		
	}
	
	
	/**
	 * 净值接口文件导出页面
	 * @return
	 */
	@RequestMapping("/exportNavInterfaceFileView")
	public String exportNavInterfaceFileView() {
		return "/business/customerEquity/navInfo/exportNavInterfaceFile";
	}
	
	/**
	 * 净值接口文件导出
	 * @return
	 */
	@RequestMapping("/exportNavInterfaceFile")
	public void exportNavInterfaceFile(@RequestParam("theDate")String theDate, @RequestParam("faCode")String faCode, HttpServletResponse response) {
		navinfoService.exportNavInterfaceFile(theDate,faCode,response);
	}
	
	/**
	 * 修改详情
	 * @return
	 */
	@RequestMapping("/updateNavDetail")
	public String updateNavDetail(@RequestParam("navBizId")String navBizId, ModelMap model) {
		NavInfoBaseVo navInfoBaseVo = navinfoService.queryNavDataById(navBizId);
		model.put("vo", navInfoBaseVo);
		return "/business/customerEquity/navInfo/navInfoUpdate";
	}
	
	
	/**
	 * 修改提交
	 * @return
	 */
	@RequestMapping("/updateNavBaseDataSubmit")
	public String updateNavSubmit(NavInfoBaseVo navInfoBaseVo) {
		navinfoService.updateNavValuesById(navInfoBaseVo);
		return "system/hint/success";
	}
	
	
	
	
	
	
}
